<template>
  <div class="userCookbookBox" v-if="userCookbook.list.length > 0">
    <div class="searchUserCook">
      <van-icon
        name="search"
        size="20"
        color="#999"
        style="margin-left: 15px"
      />
      <input type="text" placeholder="搜索用户菜谱" />
    </div>
    <div class="userCookbooks">
      <UserCookbookItem
        v-for="item in userCookbook.list"
        :key="item.r.id"
        :item="item"
      />
    </div>
  </div>
  <div class="userCookbookBox" v-else>
    <div class="none">暂未发布任何内容</div>
  </div>
</template>

<script setup lang="ts">
import UserCookbookItem from "@/components/UserCookbookItem.vue";
import { useDouguoStore } from "@/stores/douguo";
import { storeToRefs } from "pinia";
import { ref } from "vue";
import { useRouter } from "vue-router";

const douguo = useDouguoStore();

const { userCookbook } = storeToRefs(douguo);

const { updataUserCookbook } = douguo;

const route: object = useRouter();

const obj1 = ref({
  id: route.currentRoute.value.query.id,
  offset: 0,
  limit: 20,
});

updataUserCookbook(obj1);
</script>

<style lang="scss" scoped>
.userCookbookBox {
  .searchUserCook {
    margin: 0 15px;
    // width: 100%;
    height: 34px;
    border-radius: 17px;
    background-color: #f6f6f6;
    display: flex;
    align-items: center;
    margin-bottom: 15px;

    input {
      width: 100%;
      background: none;
      outline: none;
      border: 0px;
      // color: #999;
      margin-left: 5px;
      padding: 0;
      font-size: 15px;
    }

    input[type="text"]:focus,
    input[type="password"]:focus {
      background: none;
      outline: none;
    }
  }

  .none {
    color: #999;
    font-size: 16px;
    margin-top: 20px;
    text-align: center;
  }
}
</style>
